package com.xbongbong.pro.formexplain.pojo.dto;

import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.ext.FieldPermissionEntityExt;
import com.xbongbong.paas.domain.entity.ext.PaasFormEntityExt;
import com.xbongbong.paas.enums.DelEnum;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.paas.toolbox.wrap.QueryIgnore;
import com.xbongbong.paas.toolbox.wrap.UserVO;
import com.xbongbong.sys.domain.entity.UserEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 字段解释入参
 * @author 吴峰
 * @version v1.0
 * @date 2019/3/28 20:09
 * @since v1.0
 */
@Getter
@Setter
@ToString
public class HandlerExplainDTO extends BaseDTO {

    private static final long serialVersionUID = -60673450073292266L;
    /**
     * 数据id
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private Long dataId;

    /**
     * 创建者
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private String creatorId;
    /**
     * 负责人
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private List<String> ownerId;
    /**
     * 协同人
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private List<String> coUserId;
    /**
     * 字段列表
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private List<FieldAttrEntity> explainList;
    /**
     * 表单属性
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private PaasFormEntityExt paasFormEntityExt;
    /**
     * 流程权限
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private Map<String, FieldPermissionEntityExt> permissionMap;

    private Integer del;

    @Getter(onMethod_ = {@QueryIgnore})
    private List<String> subIdList;

    /**
     * 系统未启用字段是否过滤，true 过滤， false不过滤
     */
    private Boolean isFilter;

    private Integer businessType;

    @Getter(onMethod_ = {@QueryIgnore})
    private Integer saasMark;

    private Integer subBusinessType;

    private List<String> featureList;

    private Integer isOuterLink;


    private JSONObject formData;

    private Map<String, UserEntity> userMap;

    private JSONObject ownerAndCoUser;

    /**
     * 1：打印调用详情接口，0或者0则是非打印
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private Integer isPrint;
    
    public HandlerExplainDTO() {
        del = DelEnum.NORMAL.getDel();
        isFilter = true;
    }

    public HandlerExplainDTO(List<FieldAttrEntity> explainList, String corpid) {
        this.explainList = explainList;
        this.setCorpid(corpid);
    }

    /**
     * 高级权限-构造函数
     * @param creatorId
     * @param ownerId
     * @param coUserId
     * @param userId
     * @param userVO
     */
    public HandlerExplainDTO(String creatorId, List<String> ownerId, List<String> coUserId, String userId, UserVO userVO) {
        this.creatorId = creatorId;
        this.ownerId = ownerId;
        this.coUserId = coUserId;
        setUserId(userId);
        setLoginUser(userVO);
    }


    /**
     * 列表封装
     * @param corpid
     * @param userId
     * @param userVO
     * @param isFilter 系统未启用字段是否过滤，true 过滤， false不过滤
     */
    public HandlerExplainDTO(List<FieldAttrEntity> explainList, PaasFormEntityExt paasFormEntityExt, String corpid,  String userId, UserVO userVO, Boolean isFilter, Integer subBusinessType) {
        this.explainList = explainList;
        this.paasFormEntityExt = paasFormEntityExt;
        if (Objects.isNull(isFilter)) {
            isFilter = true;
        }
        this.isFilter = isFilter;
        this.subBusinessType = subBusinessType;
        setCorpid(corpid);
        setUserId(userId);
        setLoginUser(userVO);
    }


    /**
     * 高级权限-构造函数
     * @param creatorId
     * @param ownerId
     * @param coUserId
     * @param subIdList
     * @param userId
     * @param userVO
     */
    public HandlerExplainDTO(String creatorId, List<String> ownerId, List<String> coUserId, List<String> subIdList, String userId, UserVO userVO) {
        this.creatorId = creatorId;
        this.ownerId = ownerId;
        this.coUserId = coUserId;
        this.subIdList = subIdList;
        setUserId(userId);
        setLoginUser(userVO);

    }

}
